Computer administrators typically review error log files stored on a disk drive or other permanent storage media (e.g., flash drive) to investigate problems relating to the configuration and operation of devices in a computer system. These error log files contain text messages (or “log messages”) that provide warnings and/or errors (referred to herein as “warning log messages”) and descriptions and/or other information (referred to herein as “descriptive log messages”) that enable the computer administrator to better understand why a warning log message may have occurred. Log messages in an error log file pertaining to a particular device are added to the log file as a result of log requests made by a device driver communicating with the device. A device driver, as part of its typical operation, will continually request descriptive log messages to be written to the error log file. Such descriptive log messages relate to a state of the device at the time the request was made. Additionally, to the extent that an error occurs during the device driver's communication with the device, the device driver will also request that a warning log message be written to the error log file.
Continual writing of log messages to an error log file requires continual access to the disk drive through repeated disk I/O (Input/Output) operations. To reduce such repeated disk I/O operations, a device driver can allocate a message buffer (typically, as a circular buffer) in RAM (Random Access Memory) of the computer system to preliminarily store descriptive log messages. When the device driver generates a warning log message, the device driver then flushes the descriptive log messages stored in the message buffer to the error log file. In this manner, descriptive log messages that arise during a time distant from the occurrence of a warning log message are simply overwritten in the circular buffer by other descriptive log messages and are therefore never written to the error log file. This result is desirable because such overwritten descriptive log messages are not relevant to resolving a warning log message since they relate to states of the computer system during times that are distant from the occurrence of the warning log message.
Another technique to minimize disk I/O operations is to “throttle” warning log messages. In many instances a device driver repetitively generates a great many warning log messages relating to the same error or device driver state because, for example, the device driver continually tries to unsuccessfully recover from the error or because the device driver repetitively encounters the same issue generating the warning (e.g., the device has become non-responsive or is otherwise not performing as expected). Because the same issue is repeatedly encountered, the same descriptive log messages that are relevant to the issue are continually generated and inserted into the circular buffer. During a first occurrence of the warning log message, these relevant descriptive log messages are flushed from the circular buffer into the error log file. As such, the occurrence of the repeated warning log messages causes the device driver to repeatedly flush the same relevant descriptive log messages from the message buffer to the error log file, thereby unnecessarily consuming disk I/O resources.
A device driver can “throttle” back warning log messages (i.e., flush the circular buffer only on certain occurrences of the repeated warning log message) utilizing a heuristic, such as an exponential back-off algorithm, to reduce its consumption of disk I/O resources. In one example of log throttling using exponential back-off, a device driver maintains a count, referred to herein as a “throttle count,” and flushes the circular buffer each time a particular warning log message occurs until the throttle count is reached. Subsequent occurrences of the warning log message are exponentially ignored such that only the subsequent 2N occurrences (i.e., 2nd, 4th, 8th, 16th, etc.) of the warning log message cause a flush of the message buffer. To properly keep track of different warning log messages that may be simultaneously occurring, the device driver needs to maintain a count for each particular warning log message instance. The device driver therefore needs to allocate a static local variable for each particular warning log message which can significantly increase the memory requirements of the device driver.
With the prevalence of standardized physical interfaces, such as USB (Universal Serial Bus), that support multiple types of devices, current device drivers have a corresponding capability to simultaneously support multiple devices that utilize such standardized physical interfaces. For example, a particular USB device driver may support multiple device types within a particular USB “class,” such as a mass storage device class or an HID (human interface device) class. A mass storage USB device driver may support a computer system's communication with external hard drives, portable flash drives, digital cameras, portable media players and mobile phones. Similarly, an HID USB device driver may support the computer system's communication with a keyboard and a mouse, as well as joysticks, trackballs and other input devices. When such a “device class” driver simultaneously supports different connected devices, log messages are generated and stored in a circular buffer that is shared by all of the devices. As such, when the device driver generates a warning log message relating to one device, the log messages that are flushed from the message buffer to the error log file may relate to multiple devices, thereby complicating the administrator's task of isolating log messages relating to the device causing the warning log message. Furthermore, because the circular buffer has a limited size, descriptive log messages that are relevant to debugging a warning log message for one device may be inadvertently overwritten by descriptive log messages of other devices prior to being flushed to the error log file. This is particularly likely to be the case if one device has malfunctioned before another, thereby filling up the circular buffer and the error log file with log messages that have no relevance to a second device's failure. Additionally, a device driver that supports multiple devices and implements the foregoing log message throttling techniques may discard all of the warning messages related to the failure of a second failing device because throttling has occurred in response to the failure of a first device.